package net.csdn.business.common.domain.pop;

import lombok.Data;
import net.csdn.business.common.enums.ResultCodeEnum;

import java.io.Serializable;

@Data
public class PopResultVo<T> implements Serializable {
    private String msg;
    private int code;
    private T data;

    public static <T> PopResultVo<T> success(T result) {
        PopResultVo<T> res = new PopResultVo<>();
        res.setCode(ResultCodeEnum.SUCCESS.getCode());
        res.setMsg(ResultCodeEnum.SUCCESS.getMsg());
        res.setData(result);
        return res;
    }

    public static <T> PopResultVo<T> success() {
        PopResultVo<T> res = new PopResultVo<>();
        res.setCode(ResultCodeEnum.SUCCESS.getCode());
        res.setMsg(ResultCodeEnum.SUCCESS.getMsg());
        return res;
    }

    public static <T> PopResultVo<T> fail(String msg) {
        PopResultVo<T> res = new PopResultVo<>();
        res.setCode(ResultCodeEnum.FAIL.getCode());
        res.setMsg(msg);
        return res;
    }
}
